
package pyrachnid.ctrl.listener;

import pyrachnid.ctrl.Observer;
import pyrachnid.ctrl.Simulator;
import pyrachnid.model.AllocateRobot;
import pyrachnid.model.Move;
import pyrachnid.model.ground_model.Cell;
import pyrachnid.model.robot_model.Robot;
import pyrachnid.view.MainWindow;


public class listenerRobot extends Observer {

	public listenerRobot(Simulator p_sim, MainWindow p_view) {
		super(p_sim, p_view);
	}

	@Override
	public void update(Object p_o, String p_arg) {
		Robot robot = (Robot) p_o;

		if(p_arg.equals("Allocate"))
		{
			//_view.getImagePanel().alocateRobot(robot);
			robot.addOperation(new AllocateRobot(robot, robot.getAllocateFire()));
			System.out.println("INFO : Robot in : x=" + robot.getPositionX() + " y=" + robot.getPositionY() + " is now Allocated in " + this.getClass().getName());
			
		}
		else if(p_arg.equals("Position Change"))
		{
			//_view.getImagePanel().restart();
			//_view.getImagePanel().reDrawRobot(robot);
			//_view.getImagePanel().moveRobot(robot);
			robot.addOperation(new Move(robot, robot.getOldPositionX(), robot.getOldPositionY()));
		}
		else if(p_arg.equals("Not allocate"))
			{
				System.out.println("INFO : Robot in : x=" + robot.getPositionX() + " y=" + robot.getPositionY() + " is not Allocated in " + this.getClass().getName());
				robot.addOperation(new AllocateRobot(robot, new Cell(-1, -1, -1)));
			}
	}
}